﻿@using DAL
@using FCTC_Web.Models
@model FCTC_Web.Utilities.Page<Vehicle>
@{
    ViewBag.Title = "Index";
    int current = 0;
    string styletr = "";
}
<h2>
    车辆列表</h2>
<p>
    @Html.ActionLink("创建", "Create")
</p>
@Combres.HtmlExtensions.CombresLink("backjs")
@using (Html.BeginForm())
{ 
    <style>
        table tr th
        {
            padding: 0px 17px;
            text-align: center;
            line-height: 30px;
        }
        table tr td
        {
            text-align: center;
        }
    </style>
    
    <table width="100%" style="background-color: #f6fdfd; margin-top: 20px; margin-bottom: 20px;">
        <tr>
            <td style="border-left: 0px; border-right: 0px; width: 50px; text-align: right">
                按品牌:
            </td>
            <td style="border-right: 0px; border-left: 0px; width: 120px; text-align: left">
                @Html.Partial(@"~\views\shared\searchengine\VehicleBrand.cshtml")
            </td>
            <td style="border-left: 0px; border-right: 0px; width: 50px; text-align: right">
                按型号:
            </td>
            <td style="border-right: 0px; border-left: 0px; width: 120px; text-align: left">@Html.Partial(@"~\views\shared\searchengine\VehicleType.cshtml")
            </td>
            <td style="border-right: 0px; border-left: 0px; width: 50px;">
                按类型:
            </td>
            <td style="border-right: 0px; border-left: 0px; width: 120px; text-align: left">@Html.Partial(@"~\views\shared\searchengine\VehicleStyle.cshtml")
            </td>
            <td style="border-left: 0px; text-align: left;">
                <input type="submit" value="搜 索" style="margin-left: 10px; width: 70px; height: 26px;
                    border: 1px #cecece solid; line-height: 16px; font-size: 12px;" />
            </td>
        </tr>
    </table> 

    <table width="100%">
        <tr>
            <th>
                所属车店
            </th>
            <th>
                品牌
            </th>
            <th>
                型号
            </th>
            <th>
                配置
            </th>
            <th>
                公里数
            </th>
            <th>
                价格(万)
            </th>
            <th>
                录入时间
            </th>
            <th>
                排量
            </th>
            <th>
                名称
            </th>
            <th>
                状态
            </th>
            <th>
                图片(张)
            </th>
            <th>
                编辑人
            </th>
            <th>
                编辑时间
            </th>
            <th>
                操作
            </th>
        </tr>
        @foreach (var item in Model.CurrentRecords)
        {
            if (current % 2 == 1) { styletr = "background-color:#f6fdfd"; }
            else if (current % 2 == 0) { styletr = ""; }
            <tr style="@styletr">
                <td>
                    @Html.DisplayFor(modelItem => item.Shop.FullName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CarBrand)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.BrandType)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.VehicleStyle)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Miles)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Prize)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.EnrollmentDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DeliveryCapacity)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Title)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.VehicleStatus)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Imgs.Count)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UpdatedUser)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UpdateTime)
                </td>
                <td>
                    @Html.ActionLink("编辑", "Edit" + (string)ViewBag.Claim, new { id = item.ID }) |
                    @Html.ActionLink("编辑车辆图片列表", "IndexForVehicle", "Image", new { relativeId = item.ID }, null)|
                    @Html.ActionLink("详细信息", "Details", new { id = item.ID }) 
                    @if ((item.Imgs != null && item.Imgs.Count == 0)
                        && CH.GetAllData<VehicleEstimation>().FirstOrDefault(c=>c.VehicleID == item.ID)==null)
                    {
                        <span>|</span>
                        @Html.ActionLink("删除", "Delete", new { id = item.ID })
                    }
                </td>
            </tr>
                    current++;
        }
    </table>
    <center>
        @Html.Pager(Model, "/Vehicle/Index" + (string)ViewBag.Search)
    </center>
}